package com.ruoyi.system.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HospitalSubscribeUserMessageMapper;
import com.ruoyi.system.domain.HospitalSubscribeUserMessage;
import com.ruoyi.system.service.IHospitalSubscribeUserMessageService;

/**
 * 用户消息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-30
 */
@Service
public class HospitalSubscribeUserMessageServiceImpl implements IHospitalSubscribeUserMessageService 
{
    @Autowired
    private HospitalSubscribeUserMessageMapper hospitalSubscribeUserMessageMapper;

    /**
     * 查询用户消息
     * 
     * @param id 用户消息主键
     * @return 用户消息
     */
    @Override
    public HospitalSubscribeUserMessage selectHospitalSubscribeUserMessageById(Long id)
    {
        return hospitalSubscribeUserMessageMapper.selectHospitalSubscribeUserMessageById(id);
    }

    /**
     * 查询用户消息列表
     * 
     * @param hospitalSubscribeUserMessage 用户消息
     * @return 用户消息
     */
    @Override
    public List<HospitalSubscribeUserMessage> selectHospitalSubscribeUserMessageList(HospitalSubscribeUserMessage hospitalSubscribeUserMessage)
    {
        return hospitalSubscribeUserMessageMapper.selectHospitalSubscribeUserMessageList(hospitalSubscribeUserMessage);
    }

    /**
     * 新增用户消息
     * 
     * @param hospitalSubscribeUserMessage 用户消息
     * @return 结果
     */
    @Override
    public int insertHospitalSubscribeUserMessage(HospitalSubscribeUserMessage hospitalSubscribeUserMessage)
    {
        hospitalSubscribeUserMessage.setCreateTime(DateUtils.getNowDate());
        return hospitalSubscribeUserMessageMapper.insertHospitalSubscribeUserMessage(hospitalSubscribeUserMessage);
    }

    /**
     * 修改用户消息
     * 
     * @param hospitalSubscribeUserMessage 用户消息
     * @return 结果
     */
    @Override
    public int updateHospitalSubscribeUserMessage(HospitalSubscribeUserMessage hospitalSubscribeUserMessage)
    {
        hospitalSubscribeUserMessage.setUpdateTime(DateUtils.getNowDate());
        return hospitalSubscribeUserMessageMapper.updateHospitalSubscribeUserMessage(hospitalSubscribeUserMessage);
    }

    /**
     * 批量删除用户消息
     * 
     * @param ids 需要删除的用户消息主键
     * @return 结果
     */
    @Override
    public int deleteHospitalSubscribeUserMessageByIds(Long[] ids)
    {
        return hospitalSubscribeUserMessageMapper.deleteHospitalSubscribeUserMessageByIds(ids);
    }

    /**
     * 删除用户消息信息
     * 
     * @param id 用户消息主键
     * @return 结果
     */
    @Override
    public int deleteHospitalSubscribeUserMessageById(Long id)
    {
        return hospitalSubscribeUserMessageMapper.deleteHospitalSubscribeUserMessageById(id);
    }

    /**
     * 新增订单消息
     * @param orderNo
     * @param content
     */
    @Override
    public void saveOrderMessage(String orderNo, String content, Long userId) {
        HospitalSubscribeUserMessage message = new HospitalSubscribeUserMessage();
        message.setUserId(userId);
        message.setTitle("你有一条新的消息");
        message.setContent(content);
        message.setRelatedId(orderNo);
        message.setSendTime(new Date());
        this.insertHospitalSubscribeUserMessage(message);
    }
}
